////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    ZombiesVsCheerlead2Guts.h			                          //
//  Developer:				                                                  //
//  Create date:			                                                  //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class declaration for the slot gut of the        //
//               Australian Slot machine called Zombies Vs Cheerleaders       //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        2014 - Riplife Gaming.  All rights reserved.						  //
////////////////////////////////////////////////////////////////////////////////

#if !defined(__ZOMBIESVSCHEERLEADS2GUTS_H__)
#define __ZOMBIESVSCHEERLEADS2GUTS_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "slotguts.h"
#include "getrand.h"

class ZombiesVsCheerlead2Guts : public SlotGuts
{
public:
	ZombiesVsCheerlead2Guts();

	virtual ~ZombiesVsCheerlead2Guts();

private:
	// Shared enums between client and server
	#include "ZombiesVsCheerlead2Common.h"

	// Helpful lookup arrays.
	static SpinResult m_aLineWinSpinResults[][6];
	static SpinResult m_aScatterWinSpinResults[][6];

	static int8 m_aPayLineOffsets[25][5];

	// Inline functions to use with the arrays that also do
	// bounds checking.
	static SpinResult lookupLineWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static SpinResult lookupScatterWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	void tryForJackpot( SlotSpin* spin );

	SpinResult getScatterWinResult( SlotSpin* spin, uint8 testIcon, int32& scatterPositions ) const;
	
	void evaluateScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions );

	bool8 processClientData( uint8 bonusGameType, int32 bonusDataCount, int32 *bonusData );

	void initFeatureEscape();
	void initFeatureEscapePhase(uint8 Phase);
	void initFeatureFreeSpins();
	void endFeature();
	int32 applyFeatureEscapeMultiplier(uint8 iMultiplier);

	void evaluateAddedWilds(SlotSpin* spin, int32& iWildsInfected);
	bool8 isInfected(int32 iWildsInfected, uint8 reel, uint8 row);

	static uint8 getRowLineReel( uint8 Payline, uint8 Reel )
	{
		int offset = m_aPayLineOffsets[ Payline ][ Reel ];
		switch(offset)
		{
		case 1 : return 0;
				 break;
		case 0 : return 1;
				 break;
		case -1 : return 2;
			     break;
		default : return 0;
		}
	}

protected:
	//virtual int32 getNumLinesBet();

public:
	
	SpinResult getWildsWinResult( uint8* stops, bool8 RightToLeft, uint8 lineidx, int32 iWildsInfected );

    SpinResult getLineWinResultWithPossibleSubstitution( uint8* stops, uint8 testIcon, bool8 RightToLeft, uint8 lineidx, int32 iWildsInfected, bool8& wildSubstitution );
			   
		/**
         * @brief Iterate the lines played and determine winners.
         * @param spin the slot spin.
         * @see classifyStops
         */
	void classifyZombiesVsCheerlead2Stops( uint8* stops, bool8 RightToLeft, uint8 lineidx, int32 iWildsInfected, uint8& rtnresult, bool8& wildSubstitution );

	bool doesWildLineWinPayMore( SpinResult srWilds, SpinResult srOther, bool8 wildSubstitution  ) const;

    virtual void classifyResult(SlotSpin *spin);

	SpinResult classifyZombiesVsCheerlead2Scatters( SlotSpin *spin );

    virtual bool8 isValidGuts();

    virtual void getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId );



protected:
	// Override these framework functions.
	virtual void preSpinClassifyResults( SlotSpin* spin );
    virtual void postSpinClassifyResults( SlotSpin* spin );

	virtual bool8 hasSavedGames();

	virtual void Debug_SetLoserStops( uint8* pStops );

	int32 getProgressiveValue();

	virtual void initDebugFunctionMap();

};  


#endif // !defined(__ZombiesVsCheerleads2Guts_H__)
